﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace XDYRestaurant
{
    
    public partial class Login : Form
    {
        private Context.Context ctx = new Context.Context();
        public Login()
        {
            InitializeComponent();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            var text = ctx.Admins.FirstOrDefault(u => true);
            var user = ctx.Admins.FirstOrDefault(u => u.AdminPhone == txtName.Text&& u.AdminPassword == txtPwd.Text);
            var userName = ctx.Admins.FirstOrDefault(u => u.AdminPhone == txtName.Text);
            if (user != null)
            {
                Main main = new Main();
                main.Show();
                this.Hide();
            }
            else if(userName != null)
            {
                MessageBox.Show("密码错误");
                txtPwd.Text = "";
            }
            else
            {
                MessageBox.Show("用户名错误");
                txtPwd.Text = "";
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
